<?php

//长文本编辑post
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/forum/inc.php");
error_reporting(E_ERROR | E_PARSE);


//所有的参数
$g_cgival 	= array();
//存储中间数据 非输出数据 可以不用
$g_pro	 	= array();
//要显示的数据 输出数据
$g_show 	= array();

function check_cgi_pro()
{		
	global $g_cgival, $g_pro, $g_show, $config;

	//文本ID
	cgi::both($g_cgival["text_id"], "text_id", 0);
	
	//get page info 
	cgi::both($g_cgival["title"], "title", "");
	cgi::both($g_cgival["content"], "content", "");
	cgi::both($g_cgival["tags"], "tags", "");
	//check attachment is hidden
	cgi::both($g_cgival["is_hidden"], "is_hidden", 0);
	
}


function get_data()
{
	global $g_cgival, $g_pro, $g_show, $config;
	
	$title = $g_cgival["title"];
	$text_id = $g_cgival["text_id"];
	$content = $g_cgival["content"];
	$tags = $g_cgival["tags"];
	$is_hidden = $g_cgival["is_hidden"];
}


check_cgi_pro();
get_data();
show_pro();

exit;

function show_pro()
{
	global $g_cgival, $g_pro, $g_show, $config;


	if ($g_cgival['t'] == "serialize")
	{
		echo serialize($g_show);
	}
	elseif ($g_cgival['t'] == "json")
	{
		echo output::json("json", $g_show, $g_cgival['callback']);
	}
	elseif($g_cgival['t'] == "jsonp")
	{
		echo output::json("jsonp", $g_show, $g_cgival['callback']);
	}
	elseif($g_cgival['t'] == "perl")
	{
		$string = php_to_perl::php_array_to_perl_hash($g_show);
		$string = mb_convert_encoding($string, "GBK", "UTF-8");
		echo $string;
	}
	elseif($g_cgival['t'] == "iframe")
	{
		header("location:{$g_cgival['link']}");
	}
	else
	{
		echo output::json("jsonp", $g_show, $g_cgival['callback']);
	}
}
?>
